package com.yangye.otherdemo.blockingqueue;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author yangye
 * @date 2020/08/10
 */
public class ArrayBlockingQueueTest {

	public static void main(String[] args) throws InterruptedException {
		ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<>(10);
		for (int i = 0; i < 8; i++) {
			queue.put(i);
		}

		new Thread(() -> {
			try {
				Thread.sleep(1000);
				queue.put(8);
				Thread.sleep(1000);
				queue.put(9);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

		}).start();

		for (; ; ) {
			System.out.println(queue.take());
		}



	}
}
